package ass2;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;

//TODO possibleActions with standing still
public class Prey extends Agent {

	public Prey(Location spawn, Environment env) {
		super(spawn, env);
	}

	//write policy for prey
	//normally possible actions should contain  the standing still
	@Override
	void move() {
		Vector<Action> possibleActions = getPossibleActions();
		if( possibleActions.size() > 0 && Tools.RandomGenerator.nextInt(100) >= 100-100*Environment.preyMoveProb ) {
			updateLocation(Tools.randomVector(possibleActions));
		}
	}

	Vector<Action> getPossibleActions() {
		Location predatorLoc = Environment.getPredator().getLocation();
		Vector<Action> actions = getActions();
		Iterator<Action> action = actions.iterator();
		while(action.hasNext()) {
			Action a = action.next();
			if (a.x+getLocation().x == predatorLoc.x &&
					a.y+getLocation().y == predatorLoc.y) {
				action.remove();
			}
		}
		return actions;
	}

}
